package com.graduation.pojo.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.graduation.common.constans.DateConstants;
import com.graduation.common.constans.EsConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.HighlightField;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 法律文档表
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("legal_document")
@Document(indexName = EsConstants.LEGAL_DOCUMENT_INDEX)
public class LegalDocument {

    // 文档ID
    @TableId(value = "id", type = IdType.AUTO)
    @Id
    private Long id;

    // 文档标题
    @TableField("title")
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    @HighlightField()
    private String title;

    // 文档全文
    @TableField("content")
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String content;

    // 文档类型（0:法律, 1:案例, 2:判决书, 3:文章）
    @TableField("doc_type")
    @Field(type = FieldType.Integer)
    private Integer docType;

    // 发布日期
    @TableField("publish_date")
    @Field(type = FieldType.Date)
    private LocalDate publishDate;

    // 来源（如法院、期刊）
    @TableField("source")
    @Field(type = FieldType.Text)
    private String source;

    @TableField("file_url")
    @Field(type = FieldType.Text)
    private String fileUrl;

    // 关键词（逗号分隔）
    @TableField("keywords")
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String keywords;

    // 创建时间
    @TableField("create_time")
    @Transient
    private LocalDateTime createTime;

}
